package uns.fit.gis.contextmenu;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;

import uns.fit.gis.MapDrawer;
import uns.fit.gis.i18n.LocaleManager;
import uns.fit.gis.mapdrawer.ActionCode;

public class BestRouteContextMenu extends ContextMenu {
	public BestRouteContextMenu() {
		commands = new Command[8];
		commands[0] = new Command(LocaleManager.getMessage("menu"), Command.ITEM, 1);
		commands[1] = new Command(LocaleManager.getMessage("viewbestroute"), Command.ITEM, 1);
		commands[2] = new Command(LocaleManager.getMessage("clearbestroute"), Command.ITEM, 1);
		commands[3] = new Command(LocaleManager.getMessage("gotostart"), Command.ITEM, 1);
		commands[4] = new Command(LocaleManager.getMessage("gotoend"), Command.ITEM, 1);
		commands[5] = new Command(LocaleManager.getMessage("banorunbansegment"), Command.ITEM, 1);
		commands[6] = new Command(LocaleManager.getMessage("refreshbestroute"), Command.ITEM, 1);
		commands[7] = new Command(LocaleManager.getMessage("exit"), Command.EXIT, 1);
	}
	public void commandAction(Command command, Displayable displayable) {
		if(command == commands[0]) {
			MapDrawer.getMidlet().showMenuCanvas();
		}
		else if(command == commands[1]) {
			MapDrawer.getMidlet().showBestRouteList();
		}
		else if(command == commands[2]) {
			MapDrawer.getMidlet().mapCanvas.commandAction(ActionCode.CLEAR_BEST_ROUTE);
		}
		else if(command == commands[3]) {
			MapDrawer.getMidlet().mapCanvas.commandAction(ActionCode.GO_TO_SOURCE);
		}
		else if(command == commands[4]) {
			MapDrawer.getMidlet().mapCanvas.commandAction(ActionCode.GO_TO_DESTINATION);
		}
		else if(command == commands[5]) {
			MapDrawer.getMidlet().mapCanvas.commandAction(ActionCode.BAN_UNBAN_SEGMENT);
		}
		else if(command == commands[6]) {
			MapDrawer.getMidlet().mapCanvas.commandAction(ActionCode.REFRESH_BEST_ROUTE);
		}
		else if(command == commands[7]) {
			MapDrawer.getMidlet().mapCanvas.commandAction(ActionCode.DESTROY_APP);
		}
	}
}
